package com.kinglone.common.utils;


import sun.misc.BASE64Encoder;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * 加密工具
 * @author Administrator
 *
 */
public class CryptoUtil {

    public static String sha(String pws) throws Exception {
		MessageDigest md=MessageDigest.getInstance("SHA") ;//或者SHA-1 SHA1
        byte[] bt=md.digest(pws.getBytes());
        System.out.println(bt.length);
        BASE64Encoder base=new BASE64Encoder();
		String str=base.encode(bt);
        return str;
		

    }

	/*public static String md5(String pws,String salt){
		
		return new Md5Hash(pws, salt).toString();
	}
	*/
	/*public static void main(String[] args){
		String str = "admin";
		System.out.println("MD5加密："+CryptoUtil.sha(str));
	}*/
}
